package com.auok.Message;

import Util.JsonUtil;
import com.auok.Entity.UserSession;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;

import java.util.Date;

@AllArgsConstructor
@Getter
@Setter
public class SendToUserMessage {
    private Date time;
    private String fromUserId;
    private String content;

    public void Send(UserSession userSession) {

        Message message = new Message("SendToUser", JsonUtil.ToJson(this));

        String msg = JsonUtil.ToJson(message);

        System.out.println("推送消息：" + msg);

        userSession.getWebSocket().writeTextMessage(msg);

    }
}
